import {Injectable} from '@angular/core';
import {
    FormInput,
    FormSelect,
    FormDate,
    FormText,
    FormTitle,
    FormDateRange,
    FormCascader,
    FormUpload,
    FormLocation
} from '@kylin/shared';

@Injectable({
    providedIn: 'root'
})
export class DynamicFormService {

    constructor() {
    }

    forms() {
        return [
            new FormInput({
                    key: 'equal',
                    label: 'equal',
                    required: true,
                    value: '',
                    length: 12,
                    disabled: false,
                    validators: {decimalPlaces: [6], checkTypes: ['number']}
                }
            ),
            new FormInput({
                    key: 'input',
                    label: 'input',
                    required: true,
                    value: '',
                    length: 12,
                    disabled: false,
                    validators: {decimalPlaces: [6], checkTypes: ['number'], equalToValidator: ['equal']}
                }
            ),
            new FormTitle({
                key: 'formTitle',
                label: 'formTitle',
                value: 'formTitle'
            }),
            new FormInput({
                key: 'formInput',
                label: 'formInput',
                placeholder: 'formInput',
                value: ''
            }),
            new FormSelect({
                key: 'formSelect',
                label: 'formSelect',
                placeholder: 'formSelect',
                value: '',
                options: [{label: 'label', value: 'value'}]
            }),
            new FormDate({
                key: 'formDate',
                label: 'formDate',
                placeholder: 'formDate',
                value: null
            }),
            new FormText({
                key: 'formText',
                label: 'formText',
                value: 'formText'
            }),
            new FormDateRange({
                key: 'formDateRange',
                label: 'formDateRange',
                value: [],
                placeholder: 'formDateRange',
                showTime: true
            }),
            new FormCascader({
                key: 'formCascader',
                label: 'formCascader',
                value: [],
                placeholder: 'formCascader',
                options: [
                    {
                        value: 'zhejiang',
                        label: 'Zhejiang',
                        children: [
                            {
                                value: 'hangzhou',
                                label: 'Hangzhou',
                                children: [
                                    {
                                        value: 'xihu',
                                        label: 'West Lake',
                                        isLeaf: true
                                    }
                                ]
                            },
                            {
                                value: 'ningbo',
                                label: 'Ningbo',
                                isLeaf: true
                            }
                        ]
                    },
                    {
                        value: 'jiangsu',
                        label: 'Jiangsu',
                        children: [
                            {
                                value: 'nanjing',
                                label: 'Nanjing',
                                children: [
                                    {
                                        value: 'zhonghuamen',
                                        label: 'Zhong Hua Men',
                                        isLeaf: true
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }),
            new FormUpload({
                key: 'formUpload',
                label: 'formUpload',
                value: [
                    '/img/20190523/1558598519350.jpg',
                    '/img/20190523/1558598522928.jpg'
                ],
                placeholder: 'formUpload'
            }),
            new FormLocation({
                key: 'formLocation',
                label: 'formLocation',
                value: '',
                placeholder: 'formLocation'
            })
        ];
    }
}


